///////////////////////////////////////////////////////////////////////////////
// Project: Hoyo Client Game
//
// hy_player_data.cpp
// Created: 2013-7-30
// Author: Like Cheng
///////////////////////////////////////////////////////////////////////////////

#include "hy_player_data.h"
#include "hy_common_system/hy_common_func.h"
#include "hy_battle_system/hy_formation_data.h"



///////////////////////////////////////////////////////////////////////////////
//hy_player_data::hy_player_data
///////////////////////////////////////////////////////////////////////////////
hy_player_data::hy_player_data()
{
	m_formation_data = NULL;
	init();
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_logic::~hy_player_logic
///////////////////////////////////////////////////////////////////////////////
hy_player_data::~hy_player_data()
{
	DEL_POINTER( m_formation_data );
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_data::init
///////////////////////////////////////////////////////////////////////////////
bool hy_player_data::init()
{
	m_player_id = 0;
	m_net_id = 0;
	m_is_load = 0;
	m_player_value.clear();

	m_cur_copy_id = 0;
	m_cur_battle_id = 0;

	DEL_POINTER( m_formation_data );
	m_formation_data = new hy_formation_data;
	return true;
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_data::is_load_by_db
///////////////////////////////////////////////////////////////////////////////
int hy_player_data::is_load_by_db()
{
	return m_is_load;
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_data::get_player_level
///////////////////////////////////////////////////////////////////////////////
int hy_player_data::get_player_level()
{
	return hy_common_data::get_level();
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_data::get_player_battle_value
///////////////////////////////////////////////////////////////////////////////
int hy_player_data::get_player_battle_value()
{
	return 0;
}
///////////////////////////////////////////////////////////////////////////////
//hy_player_data::get_active_pet_id
///////////////////////////////////////////////////////////////////////////////
int hy_player_data::get_active_pet_id()
{
	return 0;
}

const char*	hy_player_data::get_cname()
{
	return "AAAAA";
}

int hy_player_data::get_player_occup()
{
	return m_player_value["player_occup"].asInt();
}

int hy_player_data::get_player_sex()
{
	return m_player_value["player_sex"].asInt();
}

int hy_player_data::get_player_coin()
{
	return m_player_value["player_coin"].asInt();
}

int hy_player_data::get_player_gold()
{
	return m_player_value["player_gold"].asInt();
}

int hy_player_data::get_player_icon()
{
	return m_player_value["player_icon"].asInt();
}

int	hy_player_data::get_player_model()
{
	return get_player_occup() * 10 + get_player_sex(); 
}

Json::Value hy_player_data::get_player_pet_data()
{
	return Json::Value();
}

Json::Value& hy_player_data::get_player_value()
{
	return m_player_value;
}

void hy_player_data::set_player_value( Json::Value &v )
{
	m_player_value = v;

	hy_common_data::m_common_value = v;

	m_is_load = 1;

	parse_player_data();
}

void hy_player_data::parse_player_data()
{
	set_agile( get_json_int( m_player_value, "agile" ) );
}

void hy_player_data::set_player_occup( int occup )
{
	m_player_value["player_occup"] = occup;
}

void hy_player_data::set_player_sex( int sex )
{
	m_player_value["player_sex"] = sex;
}

void hy_player_data::set_player_coin( int coin )
{
	m_player_value["player_coin"] = coin;
}

void hy_player_data::set_player_gold( int gold )
{
	m_player_value["player_gold"] = gold;
}